#include<queue>
#include <pthread.h>

using callback = void (*)(void *arg);
struct Task
{
    
    Task()
    {
        function=nullptr;
        arg=nullptr;
    }
    Task(callback f,void* arg)
    {
        this->arg=arg;
        this->function=f;
    }
    void* arg;
    callback function;
};

class TaskQueue
{

public:
    TaskQueue();
    ~TaskQueue();
    
    //添加任务
    void addTask(Task task);
    void addTask(callback f,void* arg);
    //取出任务
    Task takeTask();
    //获取当前任务
    inline size_t taskNumber()
    {
        return m_taskQ.size();
    }
private:
    pthread_mutex_t m_mutex;
    std::queue<Task> m_taskQ;


};